﻿/*
 * Defines a student object, used as part of an RFID tag attendance system.
 * Each student has a name, an RFID number, and a boolean that determines whether
 * the student is currently in class or not. Also contains a ListViewItem, used for
 * checking against ListViews.
 * 
 * Author: Charles Rosaaen
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RFID
{

    class Student
    {
        private string ID, name;
        private bool isIn_Val;
        private ListViewItem LVI_A, LVI_I, LVI_O;
        private DateTime inTime, outTime;
        public static DateTime initTime = DateTime.MinValue;

        public Student(string ID, string name)
        {
            this.ID = ID;
            this.name = name;
            isIn_Val = false;
            LVI_A = new ListViewItem(name);
            LVI_I = new ListViewItem(name);
            LVI_O = new ListViewItem(name);
            inTime = outTime = initTime;
        }

        public string getName()
        { return name; }

        public DateTime getInTime()
        { return inTime; }

        public DateTime getOutTime()
        { return outTime; }

        public void setInTime(DateTime time)
        {
            if (LVI_I.SubItems.Count > 1)
                LVI_I.SubItems.RemoveAt(1);
            inTime = time;
            LVI_I.SubItems.Add(inTime.ToString());
        }

        public void setOutTime(DateTime time)
        {
            if (LVI_O.SubItems.Count > 1)
                LVI_O.SubItems.RemoveAt(1);
            outTime = time;
            LVI_O.SubItems.Add(outTime.ToString());
        }

        public string getID()
        { return ID; }

        public bool isIn()
        { return isIn_Val; }

        public void flipIsIn()
        { isIn_Val = !isIn_Val; }

        public ListViewItem getLVI_A()
        { return LVI_A; }

        public ListViewItem getLVI_I()
        { return LVI_I; }

        public ListViewItem getLVI_O()
        { return LVI_O; }

        public override string ToString()
        { return name; }
    }
}
